<template>
  <d2-container>
    <template slot="header">
      <el-form :inline="true" :model="searchForm" ref="searchForm" size="mini" style="margin-bottom: -18px;">
        <el-form-item label="代码" prop="code">
          <el-input v-model="searchForm.code" placeholder="代码" style="width: 100px;" />
        </el-form-item>
        <el-form-item label="名称" prop="name">
          <el-input v-model="searchForm.name" placeholder="名称" style="width: 120px;" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearchFormSubmit">
            <d2-icon name="search" /> 查询
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="handleSearchFormReset">
            <d2-icon name="refresh" /> 重置
          </el-button>
        </el-form-item>
      </el-form>
    </template>
    <d2-crud ref="d2Crud" :columns="columns" :data="data" :options="options" :form-options="formOptions" :add-template="template"
      :edit-template="template" :add-rules="rules" :edit-rules="rules" @selection-change="handleSelectionChange"
      @dialog-cancel="handleDialogCancel" @row-add="handleRowAdd" @row-edit="handleRowEdit" selection-row>
      <el-button slot="header" style="margin-bottom: 5px" type="primary" size="mini" icon="el-icon-circle-plus" @click="add">
        新增
      </el-button>
      <el-button slot="header" style="margin-bottom: 5px" size="mini" icon="el-icon-edit" @click="edit">
        修改
      </el-button>
      <el-button slot="header" style="margin-bottom: 5px" type="danger" size="mini" icon="el-icon-delete" @click="batchDelete">
        删除
      </el-button>
      </d2-crud>
      <page ref="pagination" @change="fetchData()" slot="footer" />
  </d2-container>
</template>

<script>
  import crud from "@/pages/components/crud/crud";
  import defaultStyle from "@/pages/components/crud/defaultStyle";
  import config from "./config";
  import page from "@/pages/components/page";
  export default {
    components: {
      page,
    },
    mixins: [crud, defaultStyle, config],
  }
</script>
